Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checked node condition for DaemonSets when updating node. #45649

Merged
merged 1 commit into from
Jun 1, 2017

Conversation

k82cn
Copy link
Member

@k82cn k82cn commented May 11, 2017

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #45628

Release note:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 11, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 11, 2017
@0xmichalis
Copy link
Contributor

Do we want to requeue on all condition updates?

@lukaszo
Copy link
Contributor

lukaszo commented May 11, 2017

I think we should. It shouldn't happen to often.

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 11, 2017

curCond, err := v1helper.GetAvailableNodeConditionType(curNode.Status.Conditions)
if err != nil {
glog.Errorf("Failed to get current node's condition: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any reason for having this error. The helper should return nil if there is no condition.

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 11, 2017
@k82cn k82cn force-pushed the k8s_45628 branch 2 times, most recently from f78f79a to 8c8aa22 Compare May 11, 2017 12:34
@@ -498,3 +498,14 @@ func PersistentVolumeClaimHasClass(claim *v1.PersistentVolumeClaim) bool {

return false
}

// GetAvailableNodeCondition returns the available NodeCondition of node.
func GetAvailableNodeCondition(conds []v1.NodeCondition) *v1.NodeCondition {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns the first node condition whose status is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, got that. there'll be multiple condition, e.g. Disk, memory, right?


nodeConditionTypeEqual := (oldCond == nil && curCond == nil)
if oldCond != nil && curCond != nil {
nodeConditionTypeEqual = (oldCond.Type == curCond.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the first node condition is true, all other node condition updates will be ignored.

@janetkuo
Copy link
Member

@k82cn thanks for the fix! Would you add unit tests too?

@k82cn
Copy link
Member Author

k82cn commented May 12, 2017

sure, will add a unit test for that.

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 12, 2017
@k82cn k82cn changed the title [WIP] Checked node condition for DaemonSets when updating node. Checked node condition for DaemonSets when updating node. May 12, 2017

if reflect.DeepEqual(oldNode.Labels, curNode.Labels) &&
reflect.DeepEqual(oldNode.Spec.Taints, curNode.Spec.Taints) &&
v1helper.NodeConditionTypeEqual(oldCond, curCond) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just compare node conditions. No need to filter True ones before comparing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done; I filter by True with NodeConditionEqual, if Status is False or empty, ignore it.


// NodeConditionTypeEqual returns true if all condition's status & types equals;
// otherwise, returns false.
func NodeConditionTypeEqual(c1 []v1.NodeCondition, c2 []v1.NodeCondition) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to NodeConditionsEqual

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@k82cn
Copy link
Member Author

k82cn commented May 13, 2017

@k8s-bot kops aws e2e test this

@k82cn
Copy link
Member Author

k82cn commented May 13, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

return true
}

if len(c1) != 0 || len(c2) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the goal of this if?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, this's used when filtered status is true condition before. It should be removed.

@@ -1219,6 +1219,19 @@ func TestUpdateNode(t *testing.T) {
ds: newDaemonSet("ds"),
shouldEnqueue: true,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for all use cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test when some conditions are false; in this PR, user's case is about out of disk but our logic does not tight to it.

I'll open another PR for resources changed, not solution for that case now.

@janetkuo
Copy link
Member

/assign @lavalamp for approval

@janetkuo
Copy link
Member

/assign @lavalamp

@k82cn
Copy link
Member Author

k82cn commented May 18, 2017

@lavalamp , added a helper func NodeConditionEqual in v1/helper :). Do you have any comments.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2017
@k8s-github-robot k8s-github-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 23, 2017
@k82cn
Copy link
Member Author

k82cn commented May 23, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k82cn
Copy link
Member Author

k82cn commented May 24, 2017

@lavalamp , ping for approve & lgtm :).

@@ -524,3 +524,28 @@ func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinit
annotations[v1.AlphaStorageNodeAffinityAnnotation] = string(json)
return nil
}

// NodeConditionEqual returns true if all effective types ("Status" is true) equals;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't what I'd expect an "equal" function to do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I think this's "equal" for the two node condition; if we want an exactly equal, we can use DeepEqual for all fields, including timestamps.

Copy link
Member Author

@k82cn k82cn May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lavalamp , is that OK for you? I'd like to get this merged before 1.7 cuts :).

Copy link
Member

@janetkuo janetkuo May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k82cn Not just that, only the ones whose status is true is compared. This is fine because we only care about node condition updates from true to non-true (either false or unknown). I suggest renaming it to NodeInSameContion, change c1 & c2 to old & cur, and move it to be a private function under daemonset controller code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janetkuo , thanks for the comments, updated :).

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2017
@k82cn
Copy link
Member Author

k82cn commented Jun 1, 2017

@k8s-bot pull-kubernetes-unit test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

1 similar comment
@lukaszo
Copy link
Contributor

lukaszo commented Jun 1, 2017

@k8s-bot pull-kubernetes-unit test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k82cn
Copy link
Member Author

k82cn commented Jun 1, 2017

@k8s-bot pull-kubernetes-unit test this

@k82cn
Copy link
Member Author

k82cn commented Jun 1, 2017

ping for lgtm label :).

@lukaszo
Copy link
Contributor

lukaszo commented Jun 1, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: janetkuo, k82cn, kargakis, lukaszo

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k82cn
Copy link
Member Author

k82cn commented Jun 1, 2017

@k8s-bot pull-kubernetes-unit test this

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit fb76746 into kubernetes:master Jun 1, 2017
@k82cn k82cn deleted the k8s_45628 branch June 1, 2017 13:27
@k82cn
Copy link
Member Author

k82cn commented Sep 2, 2018

/sig apps

@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DaemonsetController can't feel it when node recovered from outofdisk state
8 participants